objs = lqr.o tools.o matfunction.o
heads = matfunction.h tools.h lqr.h
LIB_DIR =../lib
H_DIR = ../include
OPT = -std=gnu++11
CXXFLAGS = $(DEBUG) $(FINAL) $(OPT) $(EXTRA_OPT)
all:liblqr.a liblqr.so head

liblqr.a:$(objs)
	ar rcs  $@ $^
	@if test ! -d $(LIB_DIR); then mkdir $(LIB_DIR); fi
	cp -f $@ $(LIB_DIR)

liblqr.so:lqr.cpp tools.cpp matfunction.cpp
	g++ $^ -fPIC -std=gnu++11 -shared -o $@
	@if test ! -d $(LIB_DIR); then mkdir $(LIB_DIR); fi
	cp -f $@ $(LIB_DIR)	

$(objs):

head: $(heads)
	@if test ! -d $(H_DIR); then mkdir $(H_DIR); fi
	cp -f $^ $(H_DIR)

.PHONY:clean install uninstall

clean:
	rm -f *.o *.so *.a

install:
	cp liblqr.a /usr/local/lib
	cp liblqr.so /usr/local/lib

uninstall:
	rm /usr/local/lib/liblqr.a
	rm /usr/local/lib/liblqr.so
